﻿#ifndef __SSCLOCKWHEEL_H__
#define __SSCLOCKWHEEL_H__
#include "ssClockSolt.h"
#include "../ssTimer.h"
#include "../../thread/ssThreadBase.h"
#include "../../thread/threadLock/ssThreadLock.h"
#include "../../tools/ssIDAlloter.h"
#include "../ssTimerDispatch.h"
#include <set>

namespace StarSeeker
{

class ssClockWheel : public ssThreadBase
{
	union Tick_u
	{
		u32	tick;
		struct { u8 _l1, _l2, _l3, _l4; };
	};
public:
	ssClockWheel();
	~ssClockWheel();
	//注册消息处理类
	void BindDispatch(ssTimerDispatch* dis);
	//添加计时器
	u32 AddTime(u32 interval, ulint param1, ulint param2);
	//删除计时器
	void RemoveTimer(u32 timerId);
	//停止线程
	void ExitThread();
private:
	void AddTick();
	virtual void ThreadMemberFunc();
private:
	ssClockSolt			m_solt[SS_CLOCK_SOLT];
	Tick_u				m_tick;
	ssDiffTimer			m_timer;
	ssThreadLock		m_mutex;		//互斥量
	ssThreadLock		m_mutexDel;		//互斥量
	ssCumulationID<u32>	m_ids;
	std::set<u32>		m_del;
	ssTimerDispatch	*	m_pDispatch;
};

}
#endif
